home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Today - The Disc! 5
/
CD-ROM Today - The Disc (Issue 5)(November 1994).ISO
/
mac
/
Mac shareware
/
Education
/
RLaB
/
rlib
/
mean.r
< prev
next >
Wrap
Text File
|
1994-09-21
|
537b
|
27 lines
//-------------------------------------------------------------------//
//
// Syntax: mean ( A )
// Description:
// Calculate the mean value. If the input is a 1xN, then compute the
// mean value of all the elements.
// If the input is a MxN matrix the compute a row matrix of the mean
// value of each column of the input.
//
//-------------------------------------------------------------------//
mean = function(x)
{
local(m);
m = size (x)[1];
if( m == 1 )
{
m = size (x)[2];
}
return sum( x ) / m;
};